package com.mdd.front.validate.address;

import com.mdd.common.validator.annotation.IntegerContains;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 用户地址参数
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "用户地址参数请求对象",description = "用户地址参数请求对象")
public class UserAddressParam implements Serializable {

    private static final long serialVersionUID = 1L;

    public interface create{}
    public interface update{}
    public interface delete{}

    @ApiModelProperty(value = "id")
    @NotNull(message = "id参数必传且需大于0", groups = {update.class, delete.class})
    private Long id;

    @ApiModelProperty(value = "用户id")
    @NotNull(message = "userId参数缺失", groups = {create.class, update.class})
    @DecimalMin(value = "0", message = "userId参数值不能少于0", groups = {create.class, update.class})
    private Long userId;

    @ApiModelProperty(value = "联系人")
    @NotNull(message = "contact参数缺失", groups = {create.class, update.class})
    @Length(max = 20, message = "contact参数不能超出20个字符", groups = {create.class, update.class})
    private String contact;

    @ApiModelProperty(value = "联系电话")
    @NotNull(message = "mobile参数缺失", groups = {create.class, update.class})
    @Length(max = 20, message = "mobile参数不能超出20个字符", groups = {create.class, update.class})
    private String mobile;

    @ApiModelProperty(value = "省id")
    private Long provinceId;

    @ApiModelProperty(value = "城市id")
    private Long cityId;

    @ApiModelProperty(value = "区id")
    private Long districtId;

    @ApiModelProperty(value = "详情地址")
    @NotNull(message = "address参数缺失", groups = {create.class, update.class})
    @Length(max = 64, message = "address参数不能超出64个字符", groups = {create.class, update.class})
    private String address;

    @ApiModelProperty(value = "经度")
    private String longitude;

    @ApiModelProperty(value = "纬度")
    private String latitude;

    @ApiModelProperty(value = "是否为默认地址")
    @NotNull(message = "isDefault参数缺失", groups = {create.class, update.class})
    @IntegerContains(values = {0, 1}, message = "isDefault参数值不在符合范围", groups = {create.class, update.class})
    private Integer isDefault;
}
